Pass in the keyrecord_t of the dual-role/tapping key when calling per-key tap hold functions #15938
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
[BUG FIX]
The second
keyrecord_t*
argument given to tap hold per key functions should refer to the same key as that given in the firstuint16_t keycode
argument. All the per-key functions called inbool process_tapping(keyrecord_t *keyp)
use the same pattern :get_option(tapping_keycode, keyp)
but from what I've gathered,keyp
is not necessarily thetapping_key
so it should instead beget_option(tapping_keycode, &tapping_key)
.To illustrate my point:
Let the key on row=1, col=3 be MT(MOD_LSFT, KC_S) (hexadecimal keycode=0x6216 ) and the key on row=2, col=7 be KC_H.
Consider the following body for the
get_tapping_term
function.If we try to capitalise H by holding down the S shift modtap, we can see the following appear in the printed output:
The second printed line shows the keycode of the mod-tap but the
keyrecord_t
information ofKC_H
Isn't
keycode
andrecord
supposed to refer to the same underlying key event?You can't even really exploit it that much, it seems. I thought that perhaps this might be useful to tweak the tapping term of a specific modtap if it is combined with another key but the following doesn't increase the tapping term for
LSFT_T(KC_S)
when its tap is interrupted byKC_H
(row=2, col=7)As in, I most definitely do not need to be holding down
LSFT_T(KC_S)
for 8s before pressingKC_H
in order to capitalise it.When discussing this issue on the Discord server, sigprof also pointed out instances where the
get_tapping_term
function is called with a NULL second argument in core QMK code which presents the high risk of nullptr dereference at runtime if a user, for example, dereferences therecord
argument to fetch the keypos information in their per-key tap hold function(s). To avoid this problem, I replaced the NULLs by an empty keyrecord structure (&(keyrecord_t){}
). Let me know if there's a better substitute that I can use.Types of Changes
Issues Fixed or Closed by This PR
Checklist